/*
*作者---杨彬
*
*/
<template>
    <div>
      <div v-if="myData">
        <header>
          <div class="head-content-warp com-div-middle-ab">
            <div class="head-img-warp">
              <div class="head-img-cricle" :style="{'background-image':'url('+myData.weixinPic+')'}">
                <div class="user-level" v-text="sData.mySData.levelText+myData.memberRank"></div>
              </div>
            </div>
            <p class="user-name" v-text="myData.name"></p>
            <div class="point-value-warp">
              <section>
                <span class="point-value" v-text="sData.mySData.pointText+myData.totalPoint"></span>
                <progress value="0" max="100" class='point-bar'>
              </section>
            </div>
          </div>
        </header>
        <section class="order-stutus-nav">
          <router-link class="status-item com-div-middle-ab" :class="['status'+mindex]"
                       v-for="(mitem,mindex) in navData.navText"
          :to="mitem.url">
            <img :src="mitem.src" class="status-img">
            <p v-text="mitem.name" class="status-name"></p>
            <span class="car-number" v-show = 'mitem.number>0' v-text="mitem.number"></span>
          </router-link>
        </section>
        <div class="div-space"></div>
        <div class="function-nav">
          <router-link v-for="oitem in sData.mySData.content"
               class="function-nav-item" :to="oitem.url" @click="goCouponWay">
                <span class="nav-item-title" v-text="oitem.name"></span>
                <img class="go-arrow com-div-middle-ab"src="../../assets/my/goArrow.png" v-if="oitem.url">
          </router-link>
        </div>
      </div>
      <cake-foot :sData="sData"></cake-foot>
    </div>
</template>
<script type="text/javascript">
  import cakeFoot from "src/components/com/footer/footer.vue"
  export default{
    data(){
      return{
        myData:"",
        navData:''
      }
    },
    props:['sData'],
    beforeMount () {
      
    },
    methods:{
      getData(uId){
        this.getAjax(this.sData.url.my,{userId:uId},(res)=>{
            this.myData=res.data;
            //设置积分进度条
            setTimeout(function(){
              m$.dom('.point-bar')[0].value=res.data.totalPoint;
              m$.dom('.point-bar')[0].max=res.data.nextPoint;
            },10)
        })
      },
      goCouponWay () {
        m$.localStrages.set('prodId',{})
      }
    },
    components:{cakeFoot},
    created(){
     
      document.title=this.sData.mySData.title;
    
      this.getData(this.sData.userId);
      this.getAjax(this.sData.url.findOrderByStatusUrl,{orderStatus : "",userId :this.sData.userId},(res)=>{
          //console.log('#####');
          //console.log(this.sData);
          if(res && res.status==200){
            let othis = this;
            if(res.data&&res.data.length>0){
              this.sData.mySData.navText[0].number = 0;
              this.sData.mySData.navText[1].number = 0;
              this.sData.mySData.navText[2].number = 0;
              this.sData.mySData.navText[3].number = res.data.length;
              res.data.map((item)=>{
                if(item.orderStatus == 0){//待付款
                  othis.sData.mySData.navText[0].number = othis.sData.mySData.navText[0].number + 1;
                }else if(item.orderStatus == 4){//已发货
                  othis.sData.mySData.navText[1].number = othis.sData.mySData.navText[1].number + 1;
                }else if(item.orderStatus == 2){//配送中
                  othis.sData.mySData.navText[1].number = othis.sData.mySData.navText[1].number + 1;
                }else if(item.orderStatus == 5){//待评价
                  othis.sData.mySData.navText[2].number = othis.sData.mySData.navText[2].number + 1;
                }
                
              })
              //console.log(this.sData.mySData.navText[3].number);
              this.navData = this.sData.mySData;
            }else{
              this.sData.mySData.navText.map((item)=>{
                item.number = 0;
              })
              this.navData = this.sData.mySData;
            }
            
          }else{
            m$.template({
              val: '很抱歉,服务器开小差了',
              time: 1500
            })
          }
      })

    }
}
</script>
<style scoped lang="less">
    @import "my";
</style>
